<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2016/10/11
 * Time: 14:45
 * Project name: PHPTEST
 * File name: controller.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license   https://github.com/zhangrxiang
 */
include_once 'function.php';
if (isPOST()){
	$url = empty($_POST['url'])?'http://wp4.6.dev/':$_POST['url'];
	$ch = curl_init($url.'?json=get_post');
	$ch = curl_init("http://wp4.6.dev/?json=get_post&post_id=5") ;
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; // 获取数据返回
	curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; // 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回
	echo $output = curl_exec($ch) ;
}
if (isGET()){

	$url = "www.baidu.com";//以百度为例
	$data = array(
		'json' => 'get_post',
		'post_id' => 5,
	);
	$curl = curl_init();//初始化一个curl会话；
	$url = $ch = curl_init("http://wp4.6.dev/");
	curl_setopt($curl,CURLOPT_URL,$url);//指定访问的url
	curl_setopt($curl,CURLOPT_POST,$data);//post请求的参数，
	curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);//获取的信息以文件流的方式返回
	$data = curl_exec($curl);//执行curl;
	var_dump($data);
	curl_close($curl); // 关闭CURL会话

//	$ch = curl_init("http://wp4.6.dev/?json=get_post&post_id=5") ;
//	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; // 获取数据返回
//	curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; // 在启用 CURLOPT_RETURNTRANSFER 时候将获取数据返回
//	echo $output = curl_exec($ch) ;
}
